package borge.web.teamspirit.client.data;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import borge.web.teamspirit.client.interfaces.PersistentData;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
public class MatchAttendance implements PersistentData {

	public static final String UNANSWERED = "No answer";
	public static final String ATTENDS = "Yes";
	public static final String NOT_ATTENDS = "No";
	
	/* Encoded key generated by GAE when first saved.
	 * Guaranteed to be unique and contains mapping to 
	 * a team using gae.pk-name key defined below. */
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
    private String iEncodedKey;
	
	@Persistent
	private String iMatchKey;
	
	@Persistent
	private String iPlayerKey;
	
	@Persistent
	private Boolean iAttends;

	public MatchAttendance(){
		
	}
	
	public void setMatchKey(String aKey){
		iMatchKey = aKey;
	}
	
	public String getMatchKey(){
		return iMatchKey;
	}
	
	public void setPlayerKey(String aKey){
		iPlayerKey = aKey;
	}
	
	public String getPlayerKey(){
		return iPlayerKey;
	}
	
	public void setAttending(boolean aAttends){
		iAttends = aAttends;
	}
	
	public boolean isAttending(){
		return iAttends;
	}
	
	public String getAttendValue(){
		return iAttends ? ATTENDS : NOT_ATTENDS;
	}
	
	@Override
	public String getDisplayingWidget() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getEncodedKey() {
		return iEncodedKey;
	}

}
